<template>
    <div class="header-sticky" :class="{show:y>=78}">
        <div class="container" v-show="y>=78">
            <!-- logo -->
            <h1 class="logo"><img src="@/assets/images/logo.png" alt=""></h1>
            <HeaderNav/>
            <div class="right">
                <router-link to="/" class="right-cate">品牌</router-link>
                <router-link to="/" class="right-cate">专题</router-link>
            </div>
        </div>

    </div>
</template>

<script>
import { onMounted, ref } from 'vue'
import HeaderNav from './app-header-nav.vue'
export default {
  components: {
    HeaderNav
  },
  setup () {
    const y = ref(0)
    onMounted(() => {
      // 监听滚动事件
      window.onscroll = () => {
        const scrollTop = document.documentElement.scrollTop
        // console.log(scrollTop)
        y.value = scrollTop
      }
    })

    return { y }
  }
}
</script>

<style lang="less" scoped>
.header-sticky{
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 80px;
    background: #fff;
    z-index: 9999;
    border-bottom: 1px solid #e4e4e4;
    transform: translateY(-100%);
    display: none;
    &.show{
        transition: all 0.3s linear;
        transform: none;
        display: block;
    }
    .container{
        display: flex;
        align-items: center;
        .logo{
            width: 200px;
            height: 80px;
        }
        .right{
            width: 200px;
            display: flex;
            text-align: center;
            padding-left: 40px;
            border-left: 2px solid @themeColor;
            .right-cate{
                color:#444;
                margin: 0 20px;
                font-size: 15px;
                 &:hover{
                    color:@themeColor;
                }
            }

        }
    }
}
</style>
